package com.hkyp.ss.course.apis.dto.common;

import lombok.Data;
import org.springframework.data.domain.Page;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 分页响应对象
 *
 */
@Data
public class PageResp<T> implements Serializable{
	private static final long serialVersionUID = 1L;
	private List<T> rows = new ArrayList<>();

	private int page;

	private int pagesize;

	private long total;

	public PageResp(Page page, List<T> list) {
		this.rows = list;
		this.page = page.getNumber() + 1;
		this.pagesize = page.getSize();
		this.total = page.getTotalElements();
	}
	public PageResp( ) {

	}

	public PageResp(Page<T> page){
		this.rows = page.getContent();
		this.page = page.getNumber() + 1;
		this.pagesize = page.getSize();
		this.total = page.getTotalElements();
	}

}
